package org.example.service;

import org.example.dao.UserDao;
import org.example.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;

    @Override
    public User login(String username, String password) {
        return null;
    }

    @Override
    public List<User> getUserList(String username) {
      return userDao.getUserList(username);
    }

    @Override
    public int addUser(User user) {
        int i=userDao.addUser(user);
        return i;
    }

    @Override
    public String updateUser(User user) {
        int i =userDao.updateUser(user);
        if(i>0){
            return "success";
        }else {
            return "fail";
        }

    }

    @Override
    public String deleteUser(int id) {
       int i= userDao.deleteUser(id);
       if(i>0){
           return "success";
       }else{
           return "fail";
       }

    }
}
